# nameko run UserService/service --broker amqp://admin:wxs1995.@139.199.10.230
import importlib
from pathlib import Path

root = Path(__file__).parent


def run_all():
    services = {}
    for f in root.iterdir():
        if f.is_dir() and f.name.endswith("Service"):
            name = f.name
            service = importlib.import_module(name + '.service')
            services[name] = service
    from nameko.runners import ServiceRunner

    runner = ServiceRunner(config={"AMQP_URI": "amqp://admin:wxs1995.@139.199.10.230"})
    for name, service in services.items():
        cls = getattr(service, name)
        runner.add_service(cls)

    print('wsadsa')
    runner.start()
    # runner.stop()


if __name__ == '__main__':
    run_all()
